home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / docume1a / frmfind (.txt) < prev    next >
Visual Basic Form  |  1999-06-30  |  5KB  |  152 lines

  1. VERSION 5.00
  2. Begin VB.Form frmFind 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "                        Find Text"
  5.    ClientHeight    =   2040
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   4740
  9.    ClipControls    =   0   'False
  10.    LinkTopic       =   "Form1"
  11.    LockControls    =   -1  'True
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   2040
  15.    ScaleWidth      =   4740
  16.    ShowInTaskbar   =   0   'False
  17.    StartUpPosition =   3  'Windows Default
  18.    WhatsThisButton =   -1  'True
  19.    WhatsThisHelp   =   -1  'True
  20.    Begin VB.CheckBox Check2 
  21.       Caption         =   "Case &Sensitive"
  22.       Height          =   375
  23.       Left            =   240
  24.       TabIndex        =   6
  25.       Top             =   960
  26.       Width           =   1455
  27.    End
  28.    Begin VB.CheckBox Check1 
  29.       Caption         =   "&Whole Word Only"
  30.       Height          =   375
  31.       Left            =   240
  32.       TabIndex        =   5
  33.       Top             =   600
  34.       Width           =   1575
  35.    End
  36.    Begin VB.CommandButton cmdClose 
  37.       Cancel          =   -1  'True
  38.       Caption         =   "&Close"
  39.       Height          =   375
  40.       Left            =   3360
  41.       TabIndex        =   4
  42.       Top             =   1080
  43.       Width           =   1215
  44.    End
  45.    Begin VB.CommandButton cmdNext 
  46.       Caption         =   "Find &Next"
  47.       Height          =   375
  48.       Left            =   3360
  49.       TabIndex        =   3
  50.       Top             =   600
  51.       Width           =   1215
  52.    End
  53.    Begin VB.CommandButton cmdFind 
  54.       Caption         =   "&Find"
  55.       Height          =   375
  56.       Left            =   3360
  57.       TabIndex        =   2
  58.       Top             =   120
  59.       Width           =   1215
  60.    End
  61.    Begin VB.TextBox Text1 
  62.       Height          =   285
  63.       Left            =   1320
  64.       MaxLength       =   40
  65.       TabIndex        =   1
  66.       Top             =   120
  67.       Width           =   1815
  68.    End
  69.    Begin VB.Frame Frame1 
  70.       Height          =   975
  71.       Left            =   120
  72.       TabIndex        =   7
  73.       Top             =   480
  74.       Width           =   1815
  75.    End
  76.    Begin VB.Label Label1 
  77.       AutoSize        =   -1  'True
  78.       Caption         =   "Find What:"
  79.       BeginProperty Font 
  80.          Name            =   "MS Sans Serif"
  81.          Size            =   9.75
  82.          Charset         =   0
  83.          Weight          =   400
  84.          Underline       =   0   'False
  85.          Italic          =   0   'False
  86.          Strikethrough   =   0   'False
  87.       EndProperty
  88.       Height          =   240
  89.       Left            =   240
  90.       TabIndex        =   0
  91.       Top             =   120
  92.       Width           =   945
  93.    End
  94. Attribute VB_Name = "frmFind"
  95. Attribute VB_GlobalNameSpace = False
  96. Attribute VB_Creatable = False
  97. Attribute VB_PredeclaredId = True
  98. Attribute VB_Exposed = False
  99. Dim OriginalParenthWnd As Long
  100. Dim Position As Long
  101. Private Sub cmdClose_Click()
  102. Unload Me
  103. End Sub
  104. Private Sub cmdFind_Click()
  105. Dim FindFlags As Long
  106. On Error GoTo ErrorTrap
  107. Position = 0
  108. FindFlags = Check1.Value * 2 + Check2.Value * 4
  109. Position = frmOpenDoc.RichTextBox1.Find(Text1.Text, Position, , FindFlags)
  110. If Position >= 0 Then
  111. r = Text1.Text
  112. frmOpenDoc.SetFocus
  113. Text1.Text = r
  114. MsgBox "Document has finished searching the document." & Chr(13) & Chr(13) & Chr(34) & Text1.Text & Chr(34) & " was not found!"
  115. Text1.SetFocus
  116. Text1.SelStart = 0
  117. Text1.SelLength = Len(Text1.Text)
  118. End If
  119. Exit Sub
  120. ErrorTrap:
  121. Call ErrorTrap
  122. End Sub
  123. Private Sub cmdNext_Click()
  124. Dim FindFlags As Long
  125. On Error GoTo ErrorTrap
  126. FindFlags = Check1.Value * 2 + Check2.Value * 4
  127. Position = frmOpenDoc.RichTextBox1.Find(Text1.Text, Position + 1, , FindFlags)
  128. If Position > 0 Then
  129. p = Text1.Text
  130. frmOpenDoc.SetFocus
  131. Text1.Text = p
  132. MsgBox "Document has finished searching the document." & Chr(13) & Chr(13) & Chr(34) & Text1.Text & Chr(34) & " was not found!"
  133. Text1.SetFocus
  134. Text1.SelStart = 0
  135. Text1.SelLength = Len(Text1.Text)
  136. End If
  137. Exit Sub
  138. ErrorTrap:
  139. Call ErrorTrap
  140. End Sub
  141. Private Sub Form_Load()
  142. frmOpenDochwnd = SetWindowLong(Me.hwnd, GWW_HWNDPARENT, frmOpenDoc.hwnd)
  143. Width = 0.4 * Screen.Width
  144. Height = 0.24 * Screen.Height
  145. Left = (Screen.Width - Width) / 2
  146. Top = (Screen.Height - Height) / 2
  147. End Sub
  148. Private Sub Form_Unload(Cancel As Integer)
  149. Dim r As Long
  150. r = SetWindowLong(Me.hwnd, GWW_HWNDPARENT, OriginalParenthWnd)
  151. End Sub
  152.